function Node(val) {
    this.value = val;
    this.left = null;
    this.right = null;
}

const a = new Node('a');
const b = new Node('b');
const c = new Node('c');
const d = new Node('d');
const e = new Node('e');
const f = new Node('f');
const g = new Node('g');
const h = new Node('h');

a.left = b;
a.right = c;
b.left = d;
b.right = e;
c.left = f;
c.right = g;
e.left = h;

function depthSearch(root, target) {
    if (root == null) return false;
    if (root.value == target) return true;
    let left = depthSearch(root.left, target);
    let right = depthSearch(root.right, target);
    return left || right;
}

console.log(depthSearch(a,"r"))